var app = getApp();
Page({
  data: {
    winHeight: "",//窗口高度
    currentTab: 0, //预设当前项的值
    scrollLeft: 0, //tab标题的滚动条位置
    mylist: []
  },
  // 评价
  pingjia:function(e){
    wx.navigateTo({
      url: '../pingjia/pingjia?id=' + e.currentTarget.dataset.id,
    })
  },
  
  //删除信访
  delRicheng: function (e) {
    var that = this;
    wx.request({
      url: app.globalData.url + '/letter/letterDel/'+e.currentTarget.dataset.id,
      data: '',
      success: function (res) {
        console.log(res);
        if (res.data.status == 'success') {
          if (getCurrentPages().length != 0) {
            //刷新当前页面的数据
            getCurrentPages()[getCurrentPages().length - 1].onLoad()
          }

        }

      }
    })
    
  },

  editRicheng: function (e) {
    wx.navigateTo({
      url: '../xinfangtijiao/xinfangtijiao?id=' + e.currentTarget.dataset.id,
    })
  },
  //跳转信访详情
  goMeetDetail: function (e) {
    wx.navigateTo({
      url: '../xinfangneirong/xinfangneirong?id=' + e.currentTarget.dataset.id,
    })
  },
  //==切换导航==
  changenav: function (e) {
    var index = e.currentTarget.dataset.index;
    this.setData({
      navindex: index
    })
  },
  // 滚动切换标签样式
  switchTab: function (e) {
    this.setData({
      currentTab: e.detail.current
    });
    this.checkCor();
  },
  // 点击标题切换当前页时改变样式
  swichNav: function (e) {
    var cur = e.target.dataset.current;
    if (this.data.currentTaB == cur) { return false; }
    else {
      this.setData({
        currentTab: cur
      })
    }
  },
  //判断当前滚动超过一屏时，设置tab标题滚动条。
  checkCor: function () {
    if (this.data.currentTab > 2) {
      this.setData({
        scrollLeft: 300
      })
    } else {
      this.setData({
        scrollLeft: 0
      })
    }
  },

	/**
	 * 生命周期函数--监听页面显示
	 */
  onShow: function () {

  },

	/**
	 * 生命周期函数--监听页面隐藏
	 */
  onHide: function () {

  },

	/**
	 * 页面上拉触底事件的处理函数
	 */
  onReachBottom: function () {

  },
  onLoad: function () {
    var that = this;
    //  高度自适应
    wx.getSystemInfo({
      success: function (res) {
        var clientHeight = res.windowHeight,
          clientWidth = res.windowWidth,
          rpxR = 750 / clientWidth;
        var calc = clientHeight * rpxR - 180;
        console.log(calc)
        that.setData({
          winHeight: calc
        });
      }
    });

    wx.request({
      url: app.globalData.url + '/letter/userLetterInfo',
      data: '',
      success: function (res) {
        console.log(res);
        if (res.data.status == 'success'){
          that.setData({
            mylist: res.data.result
          })
        }
        
      }
    })
  },
  footerTap: app.footerTap
})